package ${basePackage}.domain.vo;

import ${modelPackage}.${clazz.className};
import jakarta.annotation.Generated;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Comment:  ${clazz.classComment} view
 * @author: ${author}
 * @date:   ${date}
 */
public class ${clazz.className}${viewSuffix} {

<#list clazz.fieldList as field>
    /**
     * Comment:    ${field.fieldComment}
     * Column:    ${field.columnName}
     */
    private ${field.fieldType} ${field.fieldName};
</#list>

<#list clazz.fieldList as field>
    public void ${field.setMethodName}(${field.fieldType} ${field.fieldName}) {
        this.${field.fieldName} = ${field.fieldName};
    }

    public ${field.fieldType} ${field.getMethodName}() {
        return this.${field.fieldName};
    }
</#list>

    @Override
    public String toString() {
        return "${clazz.className} {" +
<#list clazz.fieldList as field>
    <#if field_index == 0>
               "${field.fieldName}='" + ${field.fieldName} + "'" +
    <#else>
               ", ${field.fieldName}='" + ${field.fieldName} + "'" +
    </#if>
</#list>
               "}";
    }

    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>();
<#list clazz.fieldList as field>
        map.put("${field.columnName}", this.${field.fieldName});
</#list>
        return map;
    }

    public static ${clazz.className}VO model2View(${clazz.className} model) {
        ${clazz.className}VO vo = new ${clazz.className}VO();
<#list clazz.fieldList as field>
        vo.${field.setMethodName}(model.${field.getMethodName}());
</#list>
        return vo;
    }

    public static ${clazz.className} view2Model(${clazz.className}VO vo) {
        ${clazz.className} model = new ${clazz.className}();
<#list clazz.fieldList as field>
        model.${field.setMethodName}(vo.${field.getMethodName}());
</#list>
        return model;
    }

}